<!DOCTYPE html>
<html lang="zh-cn">
	<head>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1">
	    <title></title>
	    <#include "/common/meta.ftl"/>
		<script>
			$(function(){
				$("#cbAll").click(function(){
					$(".CK").prop('checked',$("#cbAll").prop('checked'));
				});
				<#if (flag!'')!=''>
				var msg = new top.$.zui.Messager('提示消息：${flag!''}', {
		                	type : 'success',
		                	fade : true,
		                	icon : 'ok-sign',
		                	time : 3000,
		                	scale : true
		    	});
				msg.show();
				</#if>
			});
			function hasChecked(){
				var cbs = $(".CK");
				for(var i=0;i<cbs.length;i++){
					if(cbs[i].checked == true){
						return true;
					}
				}
				return false;
			}
			function plDelete(){
				if(!hasChecked()){
					var msg = new top.$.zui.Messager('提示消息：请选择要批量删除的数据！', {
		                	type : 'warning',
		                	fade : true,
		                	icon : 'warning-sign',
		                	time : 3000,
		                	scale : true
			    	});
					msg.show();
				}else{
					if(confirm("您确定要删除这些数据吗？")){
						var cbs = $(".CK");
						var ids = "";
						for(var i=0;i<cbs.length;i++){
							if(cbs[i].checked == true){
								ids += cbs[i].value + ",";
							}
						}
						ids = ids.substring(0,ids.length-1);
						location.href = "./roleDelete?ids="+ids;
					}
				}
			}
			function add(){
				location.href = "./roleForm";
			}
		</script>
	</head>
	<body style="padding:5px;">
		<form action="./role" method="post">
		<div style="margin-bottom:4px;">
			<button class="btn btn-primary" onclick="add();" type="button"><i class="icon icon-plus"></i> 添加角色</button>
			<button class="btn btn-danger" onclick="plDelete();" type="button"><i class="icon icon-trash"></i> 批量删除</button>
			
			<div style="float:right;margin-bottom:4px;">
			<div class="input-group" style="width:190px;">
		   		<span class="input-group-addon">角色名称</span> 
		   		<input name="roleName" value="${roleName!''}" type="text" class="form-control" style="width:170px;">
			  	<span class="input-group-btn">
			    	<button class="btn btn-primary" type="submit"><i class="icon icon-search"></i> 搜索</button>
			  	</span>
			</div>
			</div>
		</div>
	
		<table class="table table-hover table-bordered table-condensed" style="margin:0px;">
		  	<thead>
		    	<tr>
		    		<th style="width:40px;text-align:center;"><input type="checkbox" name="cbAll" id="cbAll" /></th>
			      	<th style="text-align:center;width:220px;">角色名称</th>
			      	<th style="text-align:center;width:80px;">角色状态</th>
			      	<th style="text-align:center;width:60px;">排序</th>
			      	<th style="text-align:center;">角色描述</th>
			      	<!--<th style="text-align:center;width:200px;">角色ID</th>-->
			      	<th style="text-align:center;width:140px;">授权操作</th>
		    	</tr>
		  	</thead>
	  		<tbody>
	  			<#list data.records as x>
	  			<tr>
	  				<td style="text-align:center"><input type="checkbox" class="CK" value="${x.roleID}"/></td>
			      	<td style="text-align:left"><a href="./roleForm?id=${x.roleID}">${x.roleName?default('')}</a></td>
			      	
			      	<td style="text-align:center;">
			      		<#if x.roleStatus==1>
			      			<span style="color:green;">正常</span>
			      		<#elseif x.roleDefault==-1>
			      			<span style="color:red;">停用</span>
			      		</#if>
			      	</td>
			      	<td style="text-align:center;">${x.roleOrder?default('')}</td>
			      	<td style="text-align:left">${x.roleMemo?default('')}</td>
			      	<!--<td style="text-align:center">${x.ROLEID?default('')}</td>-->
			      	<td style="text-align:center">
			      		<a href="./grantUser2?roleId=${x.roleID}">授权用户</a>&nbsp;&nbsp;
			      		<a href="./grantApp?roleId=${x.roleID}">授权应用</a>
			      	</td>
			    </tr>
			    </#list>
	  		</tbody>
		</table>
		<#include "/common/page_v1.ftl"/>
		</form>
	</body>
</html>